<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="Author" content="http://www.webqin.net">
    <title>共享平台</title>
    <link rel="shortcut icon" href="images/favicon.ico" />
   
    <!-- Bootstrap -->
    <link href="/carworld_weixin/css/bootstrap.min.css" rel="stylesheet">
    <link href="/carworld_weixin/css/style.css" rel="stylesheet">
    <link href="/carworld_weixin/css/response.css" rel="stylesheet">
   <link href="/carworld_weixin/css/loader.min.css" rel="stylesheet">
   <script src="/carworld_weixin/js/jquery-3.3.1.min.js"></script>
   <script src="/carworld_weixin/js/bootstrap.min.js"></script>
   <script src="/carworld_weixin/js/loading.js"></script>
  </head>
  <body>
    <div class="maincont">
     <header>
      <a href="javascript:history.back(-1)" class="back-off fl"><span class="glyphicon glyphicon-menu-left"></span></a>
      <div class="head-mid">
       <h1>消费记录</h1>
      </div>
     </header>
    
     
     <!--动态显示订单信息 start  -->
     <div id="myOrderList"></div>
      <!--动态显示订单信息 start  -->
      
     <div class="height1"></div><!--布局空格 -->
   
   
   <!-- 模态框（Modal) -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">×</button>
					<h4 class="modal-title" id="myModalLabel">订单详情</h4>
					 <div id="orderDetial"></div>
				</div>
				
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭
					</button>

				</div>
			</div>
			<!-- /.modal-content -->
		</div>
	</div>
	<!-- /.modal -->
   
   
	<!-- footNav -->
	<div class="footNav">
		<dl><a href="/carworld_weixin/"><dt><span class="glyphicon glyphicon-home"></span></dt><dd>首页</dd></a></dl>
		<dl><a href="/carworld_weixin/pages/page_myVipCard.html"><dt><span class="glyphicon glyphicon-heart"></span></dt><dd>会员卡</dd></a></dl>
		<dl><a href="/carworld_weixin/pages/page_myOrder.html"><dt><span class="glyphicon glyphicon-tasks"></span></dt><dd>订单</dd></a></dl>
		<dl><a href="/carworld_weixin/user/userPage"><dt><span class="glyphicon glyphicon-user"></span></dt><dd>我的</dd></a></dl>
		<div class="clearfix"></div> 
   	</div><!-- footNav  end-->

   	
    </div><!--maincont-->

    <script src="/carworld_weixin/js/style.js"></script>
    <script>
    $(document).ready(function () { 
    	printOrder();
    	paidOrderList();
    	
    });
    
    function printOrder(){
    	$.ajax({
    		type : 'GET',
    		url : '/carworld_weixin/print/getCode',
    		contentType : 'application/json',
    		success : function(data) {
    			alert('打印success!')
    		}
    	});
    }
    
    //查看已支付订单
    function paidOrderList(){
    	$('#myOrderList').empty();
    	$.ajax({
    		type : 'GET',
    		url : '/carworld_weixin/order/paidOrderList',
    		dataType : 'json',
    		contentType : 'application/json',
    		success : function(data) {
    			var count=data.page.totalRow;
    			if(0==count){
    				$('#myOrderList').append('<div style="text-align:center;font-size:14px;color:#bbb;">您还没有已完成的订单哦~</div>');
    				loading(false);
    				return;
    			}
    			$.each(data.page.list, function(index, elem) {
    				var html=
    				 '<div class="dingdanlist"><table><tr><td colspan="2" width="65%">订单号：<strong>'+elem.shop_order_id+'</strong></td><td width="35%" align="right"><div class="qingqu"><a href="javascript:;" class="orange">已消费</a></div></td></tr>'+
    			     '<tr><td class="dingimg" width="30%"><img src="/carworld_weixin/images/car-img-001.png" /></td><td width="50%"><h3>'+elem.shop_order_remarks+'</h3><span><strong class="orange">¥'+elem.shop_order_totalprice+'</strong></span>'+
    			     '<time>下单时间：'+elem.shop_order_createtime+'</time></td><td align="right" data-toggle="modal" data-target="#myModal" onclick="showOrderDetail('+elem.shop_order_id+')"><time>明细&nbsp;></time></td></tr></table></div>';
    				$('#myOrderList').append(html);
    			});
    			loading(false);
    		}
    	});
    }
    
    
    //查看订单详情
    function showOrderDetail(orderId){
    	$('#orderDetial').empty();
    	$.ajax({
    		type : 'GET',
    		url : '/carworld_weixin/order/myOrderDetail',
    		dataType : 'json',
    		data : {
				'orderId' : orderId
			},
    		contentType : 'application/json',
    		success : function(data) {
    			var count=data.page.totalRow;
    			if(0==count){
    				$('#orderDetial').append('<div style="text-align:center;font-size:14px;color:#bbb;">订单跑丢了~</div>');
    				return;
    			}
    			$.each(data.page.list, function(index, elem) {
    	    		var html='<div class="dingdanlist"><table>'+
    	    		       '<tr><td width="75%"><h3>'+elem.spareName+'&nbsp x1</h3><time>单位：'+elem.shop_record_unit+'</time><time>下单时间：'+elem.shop_record_updatetime+'</time></td><th colspan="4">'+
    	    			   '<strong style="color:#e2ac88">¥'+elem.shop_record_actualprice+'</strong></th></tr></table></div>';
    	    		$('#orderDetial').append(html);
    	    	});
    		}
    	});
    }
    
	</script>
	
  </body>
</html>